import { http } from "@/utils/http";
import httpConfig from "@/utils/http/httpConfig";

// 管理员列表
export function adminLists(params: any) {
  console.log("params ", params);

  return http.get(httpConfig.system + "/user/list", { params });
}

// 管理员添加
export function adminAdd(params: any) {
  return http.request<any>("post", httpConfig.system + "/user", {
    data: params
  });
}

// 管理员编辑
export function adminDetail(params: any) {
  return http.request<any>("get", httpConfig.system + "/user/" + params);
}

// 管理员编辑
export function adminEdit(params: any) {
  return http.request<any>("post", httpConfig.system + "/user/edit", {
    data: params
  });
}

// 管理员删除
export function adminDelete(params: any) {
  return http.request<any>("get", httpConfig.system + "/user/del", {
    data: params
  });
}

// 管理员删除
export function adminStatus(params: any) {
  return http.request<any>("get", httpConfig.system + "/admin/disable", {
    data: params
  });
}

/**
 * 授权角色
 * @param params
 * @returns
 */
export function authRole(userId: any, roleIds: any) {
  return http.request<any>(
    "post",
    httpConfig.system + "/user/authRole?userId=" + userId,
    {
      data: roleIds
    }
  );
}

/**
 * 根据用户编号获取橘色
 * @param userId
 * @param roleIds
 * @returns
 */
export function getRoleByUserId(userId: any) {
  return http.request<any>(
    "get",
    httpConfig.system + "/user/authRole/" + userId,
    {}
  );
}
